package com.itheima.edu.info.temanager.dao;

import com.itheima.edu.info.temanager.domain.Teacher;

public class TeacherDao {
    //创建一个空间为5的老师数组
    private static Teacher[] tesArray = new Teacher[5];

    public boolean addTeacher(Teacher te) {
        //利用标记位思想,定义int index = -1,假定里面全满直接返回false
        int index = -1;

        for (int i = 0; i < tesArray.length; i++) {
            Teacher teacher = tesArray[i];
            if (teacher == null) {
                index = i;
                break;
            }
        }
        if (index == -1) {
            return false;
        } else {
            tesArray[index] = te;
            return true;
        }
    }

    public Teacher[] findAllTeacher() {
        return tesArray;
    }
}